package com.mujin.keji.collectionsystem.module.outboundtask.viewmodel;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModel;

import com.mujin.keji.collectionsystem.module.outboundtask.repository.BoundDetailBaseRepository;
import com.mujin.keji.collectionsystem.module.outboundtask.repository.IBoundDetailBaseRepository;
import com.mujin.keji.collectionsystem.module.updata.dto.VisitUserDto;

import java.io.File;
import java.util.List;

/**
 * 录音viewmodel
 *
 * @author weishixiong
 * @Time 2018-04-24
 */
public class RecordViewModel extends ViewModel {


    private LiveData<List<File>> fileCountLiveData;
    private LiveData<List<VisitUserDto>> listLiveData;


    private IBoundDetailBaseRepository repository;

    public LiveData<List<File>> getFileCountLiveData() {

        loadRecord();
        return fileCountLiveData;
    }

    public LiveData<List<VisitUserDto>> getRecordFilesCountById(String applyId,String userCount) {
        getRecordById(applyId,userCount);
        return listLiveData;
    }

    /**
     * 根据ID 筛选录音文件
     *
     * @param applyId
     */
    private void getRecordById(String applyId,String userCount) {
        repository = new BoundDetailBaseRepository();
        this.listLiveData = repository.getRecordFilesCountById(applyId,userCount);
    }

    /**
     * 加载全部录音文件
     */
    private void loadRecord() {
        repository = new BoundDetailBaseRepository();
        this.fileCountLiveData = repository.getRecordFilesCount();
    }
}
